var base = +new Date(2020, 0, 0);
var oneDay = 24 * 3600 * 1000;
var date = [];

var data = [Math.random() * 300];
var data2 = [Math.random() * 300];
var data3 = [Math.random() * 300];
for (var i = 1; i < 367; i++) {
  var now = new Date((base += oneDay));
  date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join("/"));
  data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
  data2.push(Math.round((Math.random() - 0.5) * 20 + data2[i - 1]));
  data3.push(Math.round((Math.random() - 0.5) * 20 + data3[i - 1]));
}
const a = {
  tooltip: {
    trigger: "axis",
    position: function (pt) {
      return [pt[0], "10%"];
    },
  },
  title: {
    left: "center",
    text: "基金",
  },
  xAxis: {
    type: "category",
    boundaryGap: false,
    data: date,
    axisLabel: {
      formatter: function (value, index) {
        var date = new Date(value);
        var texts = [date.getMonth() + 1, date.getDate()];
        return texts.join("/");
      },
    },
  },
  yAxis: {
    type: "value",
  },
  series: [
    {
      name: "上证50",
      type: "line",
      symbol: "none",
      sampling: "average",
      itemStyle: {
        color: "#CA76C4",
      },
      data: data,
    },
    {
      name: "当前基金",
      type: "line",
      symbol: "none",
      sampling: "average",
      itemStyle: {
        color: "#EFAA4E",
      },
      data: data2,
    },
    {
      name: "深证50指数",
      type: "line",
      symbol: "none",
      sampling: "average",
      itemStyle: {
        color: "#75CFA0",
      },
      data: data3,
    },
  ],
};
